package day10.ZiXi;

import java.util.HashMap;
import java.util.Set;

public class MapDemo001 {
    public static void main(String[] args) {
        //创建集合对象
        HashMap<String,String> hm = new HashMap<>();
        //添加元素
        hm.put("张无忌", "赵敏");
        hm.put("郭靖", "黄蓉");
        hm.put("杨过", "小龙女");
        //获取所有键的集合。用keySet()方法实现
        Set<String> s1 = hm.keySet();
        for (String s2 : s1) {
            ////根据键去找值。用get(Object key)方法实现
            String s3 = hm.get(s2);
            System.out.println(s2+"<-->"+s3);
        }
    }
}
